import android.content.Context
import android.view.ViewGroup
import android.widget.ImageView
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.hbcysd.qybfq.R
import com.cszy.yydqbfq.bean.IndexGridBean

// 添加 BannerAdapter 内部类
 class IndexBannerAdapter : BaseQuickAdapter<IndexGridBean, QuickViewHolder>() {


    // 单例模式，返回预设 bannerImages 的 adapter 实例
    companion object {
        @JvmStatic
        fun getInstance(): IndexBannerAdapter {
            val adapter = IndexBannerAdapter()
            adapter.submitList(adapter.bannerImages)
            return adapter
        }
    }


    private val bannerImages: List<IndexGridBean>
        get() = listOf(
            IndexGridBean("金曲榜", R.mipmap.ic_jinqu,0,""),
            IndexGridBean("摇滚",R.mipmap.ic_yaogun, 0,""),
            IndexGridBean("民谣", R.mipmap.ic_minyao,0,""),
        )

    override fun onBindViewHolder(
        holder: QuickViewHolder,
        position: Int,
        item: IndexGridBean?
    ) {
        holder.getView<ImageView>(R.id.iv_banner).setImageResource(item?.img ?: 0)
    }


    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_banner, parent)
    }
}